<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('下拉框')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
    <th:block th:include="include :: header('新增【栏目标题】')" />
    <th:block th:include="include :: header('Summernote富文本编辑器')" />
    <th:block th:include="include :: summernote-css" />
</head>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-title-add">
            <!--事先 从后台加载栏目类型 todo -->
            <div class="form-group">    
                <label class="col-sm-3 control-label">栏目类型：</label>
                <!--bootstrap-select下拉框-->
                <div class="col-sm-9">
                    <select class="form-control noselect2 selectpicker" name="websiteTypeId" id="websiteTypeId" >
                        <option value="">--请选择栏目大类--</option>
                        <option  th:each="c:${list}"  th:value="${c.id}" th:text="${c.websiteTypeName}" value="1">蔬菜</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">栏目标题：</label>
                <div class="col-sm-9">
                    <input name="websiteTitleName" class="form-control" type="text" id="websiteTitleName">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">栏目内容：</label>
                <div class="col-sm-9">
                    <input type="hidden" name="content" id="content"/>
                    <div class="summernote" name="content" id="summernote" >
                    </div>
                </div>
            </div>
<!--            <input  style="margin-left: 550px" class="btn btn-success" type="button" onclick="su();" value="提交" >-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: summernote-js" />
    <script type="text/javascript">
        $(document).ready(function () {
            $('.summernote').summernote({
                lang: 'zh-CN',
                height: '300px'
            });
        });
        var prefix = ctx + "website/title"
        $("#form-title-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var websiteTypeId=$("#websiteTypeId").val();
                var websiteTitleName =$("#websiteTitleName").val();
                var summernote = $("#summernote").summernote('code');
                var data= {websiteTypeId:websiteTypeId,websiteTitleName:websiteTitleName,content:summernote};
                $.operate.save1(prefix + "/add", data);
            }
        }
        // function su() {
        //     var websiteTypeId=$("#websiteTypeId").val();
        //     var websiteTitleName =$("#websiteTitleName").val();
        //     var summernote = $("#summernote").summernote('code');
        //     var data= {websiteTypeId:websiteTypeId,websiteTitleName:websiteTitleName,content:summernote};
        //     $.ajax({
        //         //几个参数需要注意一下
        //         type: "POST",//方法类型
        //         dataType: "json",//预期服务器返回的数据类型
        //         url: "/website/title/add" ,//url
        //         contentType:"application/json",
        //         data:JSON.stringify(data),
        //         success: function (result) {
        //             console.log(result);//打印服务端返回的数据(调试用)
        //             if (result.code == 0) {
        //                 //友好提示
        //                 layer.msg("新增栏目内容成功", {icon: 6});
        //                 // todo 重定向到列表页
        //             }
        //         },
        //         error : function() {
        //             alert("异常！");
        //         }
        //     });
        // }

    </script>
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
</body>
</html>